package com.fivestar.finance.app.ui.message;

import android.content.Context;

import com.fivestar.finance.app.bean.AuthorInfo;
import com.fivestar.finance.app.core.mvp.BasePresenter;
import com.fivestar.finance.app.injector.scope.ActivityScope;
import com.fivestar.finance.library.utils.ToastUtils;

import java.util.List;

import javax.inject.Inject;

/**
 * 简要描述
 *  
 *  @author Derek.Kidd
 * @version V1.0.0
 * @date 2016/8/23 9:33
 */
@ActivityScope
public class MessagePrecenter extends BasePresenter<IMessageView> {


    private boolean hasNextPage = true;

    @Inject
    public MessagePrecenter() {

    }

    void getData() {
        getMvpView().showLoading();
        getMvpView().showContent();
        getMvpView().onRefreshCompleted();
        getMvpView().onLoadCompleted(true);
    }

    public void onRefresh() {
        getMvpView().showLoading();

        getMvpView().showContent();
        getMvpView().onRefreshCompleted();
        getMvpView().onLoadCompleted(true);
    }

    public void onReload() {
        getData();
    }

    public void onLoadMore() {

        if (!hasNextPage) {
            ToastUtils.show((Context)getMvpView(),"没有更多了~",ToastUtils.LENGTH_LONG);
            getMvpView().onLoadCompleted(false);
            return;
        }
        List<AuthorInfo> list = AuthorInfo.createTestData();

        getMvpView().notifyRecyclerView(list);
        getMvpView().onRefreshCompleted();
        getMvpView().onLoadCompleted(hasNextPage);
    }
}
